package cn.com.css.taxInspection.workquality.controller;

import cn.com.css.taxInspection.attention.entity.AjcxRecord;
import cn.com.css.taxInspection.attention.entity.AttentionCase;
import cn.com.css.taxInspection.attention.entity.Income;
import cn.com.css.taxInspection.attention.service.AttentionService;
import cn.com.css.taxInspection.common.aop.annotation.LogAnnotation;
import cn.com.css.taxInspection.common.result.DataResult;
import cn.com.css.taxInspection.gt3.entity.JcAjxxEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjEntity;
import cn.com.css.taxInspection.gt3.entity.JcSyAjjbxxZsEntity;
import cn.com.css.taxInspection.gt3.service.JcAjxxService;
import cn.com.css.taxInspection.gt3.service.JcSyAjjbxxZsService;
import cn.com.css.taxInspection.statistics.service.StatisticsService;
import cn.com.css.taxInspection.statistics.vo.AjxzReq;
import cn.com.css.taxInspection.statistics.vo.IndexDataScopeReq;
import cn.com.css.taxInspection.statistics.vo.JcjfReq;
import cn.com.css.taxInspection.system.entity.SysUser;
import cn.com.css.taxInspection.system.service.UserService;
import cn.com.css.taxInspection.system.service.impl.HttpSessionService;
import cn.com.css.taxInspection.thirdparty.vo.InspectRequestData;
import cn.com.css.taxInspection.util.TsBqUtils;
import cn.com.css.taxInspection.workflow.constants.WorkflowConstants;
import cn.com.css.taxInspection.workflow.entity.WorkflowCompensateEntity;
import cn.com.css.taxInspection.workflow.entity.WorkflowInspectionHearEntity;
import cn.com.css.taxInspection.workflow.entity.WorkflowLogEntity;
import cn.com.css.taxInspection.workflow.entity.WorkflowLogSurveyEntity;
import cn.com.css.taxInspection.workflow.service.WorkflowCompensateService;
import cn.com.css.taxInspection.workflow.service.WorkflowInspectionHearService;
import cn.com.css.taxInspection.workflow.service.WorkflowLogService;
import cn.com.css.taxInspection.workflow.service.WorkflowLogSurveyService;
import cn.com.css.taxInspection.workquality.vo.req.SelectchiefReqVo;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 数据统计
 *
 * @author wenbin
 * @version V1.0
 */
@RequestMapping("/workflow/statistics")
@RestController
@Api(tags = "案件统计")
public class StatisticsInspectHearController {

    @Autowired
    private JcSyAjjbxxZsService jcSyAjjbxxZsService;
    @Autowired
    private HttpSessionService httpSessionService;
    
    @PostMapping("/inspect")
    @ApiOperation(value = "检查")
	@DS("oracle")
	public DataResult inspect(@RequestBody JcSyAjjbxxZsEntity jcSyAjjbxxZs) {
    	String currentDeptId = httpSessionService.getCurrentDeptId();
    	
    	jcSyAjjbxxZs.setTaxorgcode(currentDeptId.substring(0, 9));
    	
    	String createStart = jcSyAjjbxxZs.getCreateStart();
    	String createEnd = jcSyAjjbxxZs.getCreateEnd();
    	if(TsBqUtils.isNotNull(createStart)){
    		String createStartReplace = createStart.replaceAll(" ", "");
    		jcSyAjjbxxZs.setCreateStart(createStartReplace);
    	}
    	
    	if(TsBqUtils.isNotNull(createStart)){
    		String createEndReplace = createEnd.replaceAll(" ", "");
    		jcSyAjjbxxZs.setCreateEnd(createEndReplace);
    	}
    	
        return jcSyAjjbxxZsService.getStatisticsInspect(jcSyAjjbxxZs);
        
    }
    

    @PostMapping("/inspectHearDetail")
    @ApiOperation(value = "检查和审理明细数据")
    public DataResult inspectHearDetail(@RequestBody JcSyAjjbxxZsEntity jcSyAjjbxxZs) {
    	

    	String mark = jcSyAjjbxxZs.getMark();
    	
    	if(TsBqUtils.isNull(mark)){
    		return DataResult.fail("mark入参不能为NULL!");
    	}
    	
    	if(TsBqUtils.isNull(jcSyAjjbxxZs.getTaxorgcode())){
    		return DataResult.fail("taxorgcode入参不能为NULL!");
    	}
    	
    	// String currentDeptId = httpSessionService.getCurrentDeptId();
    	// jcSyAjjbxxZs.setTaxorgcode(currentDeptId.substring(0, 9));
    	
    	String createStart = jcSyAjjbxxZs.getCreateStart();
    	String createEnd = jcSyAjjbxxZs.getCreateEnd();
    	if(TsBqUtils.isNotNull(createStart)){
    		String createStartReplace = createStart.replaceAll(" ", "");
    		jcSyAjjbxxZs.setCreateStart(createStartReplace);
    	}
    	
    	if(TsBqUtils.isNotNull(createStart)){
    		String createEndReplace = createEnd.replaceAll(" ", "");
    		jcSyAjjbxxZs.setCreateEnd(createEndReplace);
    	}
    	
        return jcSyAjjbxxZsService.getinspectHearDetail(jcSyAjjbxxZs);
        
    }
    
    
    
    @PostMapping("/hear")
    @ApiOperation(value = "审理")
    public DataResult hear(@RequestBody JcSyAjjbxxZsEntity jcSyAjjbxxZs) {
    	
    	String currentDeptId = httpSessionService.getCurrentDeptId();
    	
    	jcSyAjjbxxZs.setTaxorgcode(currentDeptId.substring(0, 9));
    	
    	String createStart = jcSyAjjbxxZs.getCreateStart();
    	String createEnd = jcSyAjjbxxZs.getCreateEnd();
    	if(TsBqUtils.isNotNull(createStart)){
    		String createStartReplace = createStart.replaceAll(" ", "");
    		jcSyAjjbxxZs.setCreateStart(createStartReplace);
    	}
    	
    	if(TsBqUtils.isNotNull(createStart)){
    		String createEndReplace = createEnd.replaceAll(" ", "");
    		jcSyAjjbxxZs.setCreateEnd(createEndReplace);
    	}
    	
        return jcSyAjjbxxZsService.getStatisticsHear(jcSyAjjbxxZs);
    }
    
}